package com.xh209051017.myapplication5;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class IncreaseActivity extends AppCompatActivity {
    private EditText met_name,met_money,met_position,met_lb,met_time;
    private MySqlite mySqlite;
    private SQLiteDatabase db;

    private Button mlook_btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_increase);
        met_name=findViewById(R.id.et_name);
        met_money=findViewById(R.id.et_money);
        met_time=findViewById(R.id.et_time);
        met_position=findViewById(R.id.et_position);
        met_lb=findViewById(R.id.et_lb);
        mlook_btn=findViewById(R.id.look_btn);
        mlook_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ContentValues values=new ContentValues();
                values.put("n",met_name.getText().toString());
                values.put("x",met_money.getText().toString());
                values.put("t",met_time.getText().toString());
                values.put("tt",met_lb.getText().toString());
                values.put("p",met_position.getText().toString());
                db.insert("course_info",null,values);
                Toast.makeText(IncreaseActivity.this, "添加！", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(IncreaseActivity.this,MainActivity.class));
                finish();
            }
        });
        mySqlite=new MySqlite(IncreaseActivity.this);
        db=mySqlite.getWritableDatabase();
    }
}